<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>修改分数</title>
    <link rel="stylesheet" href="/css/lay.css">
    <link rel="stylesheet" href="/css/styles.css">
    <script src="layui.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body class="layui-layout-body" style="background-color: #F2F2F2">
<jsp:include page="/teacher/tHeader.jsp"></jsp:include>
<jsp:include page="/teacher/teacherNav.jsp"></jsp:include>

<%
//    String sid= (String) request.getParameter("sid");
//    String sname= (String) request.getParameter("sname");
//    String cid= (String) request.getParameter("cid");
//    String cname= (String) request.getParameter("cname");
//    String cinfo= (String) request.getParameter("cinfo");
//    String score= (String) request.getParameter("score");
//    out.print(cid + "\t" + sid);
//    System.out.println(cid + "\t" + sid);


%>
<div class="layui-layout layui-layout-admin">
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <span class="layui-breadcrumb">
                <a href="">教师端</a>
                <a href="">课程信息</a>
                <a><cite>修改学生分数</cite></a>
            </span>
<%--            <form class="layui-form" action="course/updatescore" style="padding-top: 50px" method="post">--%>
                <div class="layui-form-item">
                    <label class="layui-form-label">学号</label>
                    <div class="layui-input-block">
                        <input type="text" name="student-id" id="sid" value="<%=request.getParameter("sid").toString()%>" readonly="readonly" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="student-name" id="sname" value="<%=request.getParameter("sname").toString()%>" readonly="readonly" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">课程号</label>
                    <div class="layui-input-block">
                        <input type="text" name="course-id" id="cid" value="<%=request.getParameter("cid").toString()%>" readonly="readonly" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">课程名</label>
                    <div class="layui-input-block">
                        <input type="text" name="course-name" value="<%=request.getParameter("cname").toString()%>" readonly="readonly" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">课程介绍</label>
                    <div class="layui-input-block">
                        <input type="text" name="course-info" value="<%=request.getParameter("cinfo").toString()%>" readonly="readonly" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">学生分数</label>
                    <div class="layui-input-block">
                        <input type="text" name="student-score" id="score" value="<%=request.getParameter("score").toString()%>" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="updateScore()">修改</button>
                        <span style="padding-left: 20px;">${update_msg}</span>
                    </div>
                </div>
<%--            </form>--%>

        </div>
    </div>
</div>


<script type="text/javascript">
    function updateScore() {
        let cid = document.getElementById("cid").value
        let sid = document.getElementById("sid").value
        let score = document.getElementById("score").value
        // alert(cid+'-'+sid+"-"+score);
        $.ajax({
            url: '../course/updatescore/' + cid + '/' + sid +'/' + score,
            type: 'get',
            dataType: 'text',
            success: function (res) {
                if (res == 'yes') {
                    alert('分数更新成功');
                } else {
                    alert('分数更新失败,请重试……');
                }
            }
        });
    }


    $("#nav li:nth-child(1) dl dd:nth-child(4)").addClass("layui-this");
    $("#nav li:nth-child(1)").addClass("layui-nav-itemed");
</script>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;
        element.init();
    });
</script>

<script>
    //Demo
    layui.use('form', function(){

    });
</script>

</body>
</html>